package com.aspose.cells;

public class Trendline extends Line {
   private Series e;
   private boolean f;
   private int g;
   private String h;
   int d = 2;
   private int i = 2;
   private double j;
   private double k;
   private boolean l;
   private boolean m;
   private double n;
   private DataLabels o;
   private boolean p;
   private int q;
   private ShapePropertyCollection r;

   Series a() {
      return this.e;
   }

   Trendline(Series parent, int type) {
      super((Chart)parent.h().d(), parent);
      this.g = type;
      this.f = true;
      this.a(parent);
      this.e = parent;
   }

   Trendline(Series parent) {
      super((Chart)parent.h().d(), parent);
      this.f = true;
      this.a(parent);
      this.e = parent;
   }

   Trendline(Series parent, int type, String name) {
      super((Chart)parent.h().d(), parent);
      this.g = type;
      this.h = name;
      this.a(parent);
      this.e = parent;
   }

   private void a(Series var1) {
      if (var1.h().d().H() == 2) {
         this.setWeight(1);
      } else {
         this.c(0.75D);
      }

   }

   public boolean isNameAuto() {
      return this.f;
   }

   public void setNameAuto(boolean value) {
      this.f = value;
   }

   public int getType() {
      return this.g;
   }

   void a(int var1) {
      this.g = var1;
   }

   public String getName() {
      return this.h;
   }

   public void setName(String value) {
      this.h = value;
      if (value != null && !"".equals(value)) {
         this.f = false;
      }

   }

   public int getOrder() {
      return this.d;
   }

   public void setOrder(int value) {
      if (value >= 2 && value <= 6) {
         this.d = value;
      } else {
         throw new IllegalArgumentException("Invalid the trendline order");
      }
   }

   public int getPeriod() {
      return this.i;
   }

   public void setPeriod(int value) {
      int var2 = 0;
      if (this.e.l() != null) {
         var2 = this.e.l().k();
      }

      if (value >= 2 && value <= var2) {
         this.i = value;
      } else {
         throw new IllegalArgumentException("This value should be between 2 and  the number of the chart points in the series.");
      }
   }

   void o(int var1) {
      this.i = var1;
   }

   public double getForward() {
      return this.j;
   }

   public void setForward(double value) {
      if (value < 0.0D) {
         throw new IllegalArgumentException("The forward value must be greater than and equal to zero");
      } else {
         this.j = value;
      }
   }

   public double getBackward() {
      return this.k;
   }

   public void setBackward(double value) {
      if (value < 0.0D) {
         throw new IllegalArgumentException("The backward value must greater than and equal to zero");
      } else if (!ChartCollection.k(this.e.getType()) && !ChartCollection.q(this.e.getType()) && value > 0.5D) {
         throw new IllegalArgumentException("The backward value must be between 0 and 0.5 when the chart type is column");
      } else {
         this.k = value;
      }
   }

   void a(double var1) {
      this.k = var1;
   }

   public boolean getDisplayEquation() {
      return this.l;
   }

   public void setDisplayEquation(boolean value) {
      this.l = value;
      if (value && this.o == null) {
         this.o = new DataLabels(this, this.e.h().d());
      }

   }

   public boolean getDisplayRSquared() {
      return this.m;
   }

   public void setDisplayRSquared(boolean value) {
      this.m = value;
      if (value && this.o == null) {
         this.o = new DataLabels(this, this.e.h().d());
      }

   }

   public double getIntercept() {
      return this.n;
   }

   public void setIntercept(double value) {
      this.n = value;
      this.p = true;
   }

   public DataLabels getDataLabels() {
      if (this.o == null) {
         this.o = new DataLabels(this, this.e.h().d());
      }

      return this.o;
   }

   DataLabels b() {
      return this.o;
   }

   boolean c() {
      return this.p;
   }

   int d() {
      return this.q;
   }

   void p(int var1) {
      this.q = var1;
   }

   public LegendEntry getLegendEntry() {
      LegendEntryCollection var1 = this.e.h().d().getLegend().getLegendEntries();
      return var1.get(this.q + this.e.h().getCount());
   }

   ShapePropertyCollection e() {
      if (this.r == null) {
         this.r = new ShapePropertyCollection(this.e.s().a().a(), this, 6);
      }

      return this.r;
   }

   public boolean isInterceptAuto() {
      return this.p;
   }

   public void setInterceptAuto(boolean isInterceptAuto) {
      this.p = isInterceptAuto;
   }
}
